# Maintainer: MoetaYuko <loli at yuko dot moe>

# options
if [ x"$_srcinfo" == "xt" ] ; then
  : ${_autoupdate:=false}
elif [ -z "$_pkgver" ] ; then
  : ${_autoupdate:=true}
else
  : ${_autoupdate:=false}
fi

# basic info
pkgbase=material-symbols-git
pkgname=(
  ttf-material-symbols-variable-git
  woff2-material-symbols-variable-git
)
pkgver=4.0.0.r91.ga90037f8
pkgrel=1
pkgdesc="Material Design icons by Google"
url="https://gitee.com/strr/material-design-icons"
license=('Apache')
arch=(any)

_pkgver=$pkgver

# sources
_dl_url="https://gitee.com/strr/material-design-icons/raw/master"
_dl_files=(
  "variablefont/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf"
  "variablefont/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].woff2"
  "variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].woff2"
  "variablefont/MaterialSymbolsSharp[FILL,GRAD,opsz,wght].woff2"
)
for _src in ${_dl_files[@]} ; do
  local _name="${_src#*/}"
  local _base="${_name%.*}"
  local _ext="${_name##*.}"
  source+=("$_base-$_pkgver.$_ext"::"$_dl_url/$_src")
  sha256sums+=('SKIP')
done

# common functions
pkgver() {
  echo "${_pkgver:?}"
}

package_ttf-material-symbols-variable-git() {
  pkgdesc+=" - variable fonts"
  provides=("${pkgname%-git}")
  conflicts=("${pkgname%-git}")

  for i in *wght*.ttf ; do
    local _ext="${i##*.}"
    local _filename="${i%-$_pkgver.$_ext}"
    install -Dm644 "$i" "$pkgdir/usr/share/fonts/${pkgname%-git}/$_filename.$_ext"
  done
}

package_woff2-material-symbols-variable-git() {
  pkgdesc+=" - variable fonts"
  provides=("${pkgname%-git}")
  conflicts=("${pkgname%-git}")

  for i in *.woff2 ; do
    local _ext="${i##*.}"
    local _filename="${i%-$_pkgver.$_ext}"
    install -Dm644 "$i" "$pkgdir/usr/share/fonts/${pkgname%-git}/$_filename.$_ext"
  done
}
